/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-4-8
 * Time: 下午7:20
 * To change this template use File | Settings | File Templates.
 */
$.fn.qyjgtree = function (type) {
    var option = {
        url:$.webPath() + '/organ/qyjg/qyjg_tree?type=' + type,
        panelHeight:'200'
    }
    this.combotree($.createArg(option, arguments));
}


$.fn.qyjglscombobox = function () {
    var option = {
        url:$.webPath() + '/organ/qyjg/qyjglsList',
        valueField:'id',
        textField:'jc',
        panelHeight:'200'
    }
    this.combobox($.createArg(option, arguments));
}



$.fn.qyjgejzhcombobox = function (qyjgId) {
    var option = {
        url:$.webPath() + '/organ/qyjg/findEjzhKhId?qyjgId=' + qyjgId,
        valueField:'id',
        textField:'jc',
        panelHeight:'200'
    }
    this.combobox($.createArg(option, arguments));
}



$.fn.allqyjgcombobox = function (multi) {
    var option = {
        url:$.webPath() + "/organ/qyjg/qyjgljList",
        //loader: qyjgLoader,
        //mode: 'remote',
        valueField:'id',
        textField:'jc',
        multiple:multi,
        panelHeight:'200'
    }
    this.combobox($.createArg(option, arguments));
}

$.fn.qyjgcombobox = function (multi) {
    var option = {
        url:$.webPath() + '/organ/qyjg/qyjgmcList',
//        loader: qyjgLoader,
//        mode: 'remote',
        valueField:'id',
        textField:'jc',
        multiple:multi,
        panelHeight:'500'
    }
    this.combobox($.createArg(option, arguments));
}

//下属企业机构
$.fn.xsqyjgcombobox = function (qyjgId) {
    var option = {
        url:$.webPath() + '/organ/qyjg/nbjgList?qyjgId=' + qyjgId,
        valueField:'id',
        textField:'jc',
        multiple:false,
        panelHeight:'100'
    }
    this.combobox($.createArg(option, arguments));
}

//零售客户查询
$.fn.lskhcombobox = function (multi) {
    var option = {
        url:$.webPath() + '/organ/qyjg/qyjgmcList',
        loader:qyjgLoader,
        mode:'remote',
        valueField:'id',
        textField:'jc',
        multiple:multi,
        panelHeight:'200'
    }
    this.combobox($.createArg(option, arguments));
}

//头部查询框的combobox
$.fn.qyjgcomboboxforsearch = function () {
    var option = {
        loader:qyjgLoader,
        mode:'remote',
        valueField:'id',
        textField:'jc',
        panelHeight:'200'
    }
    this.combobox($.createArg(option, arguments));
    this.zwcomboboxbug();
}

$.fn.lskhcomboboxforsearch = function () {
    var option = {
        loader:lskhLoader,
        mode:'remote',
        valueField:'id',
        textField:'jc',
        panelHeight:'200'
    }
    this.combobox($.createArg(option, arguments));
    this.zwcomboboxbug();
}

//头部查询框的combobox
$.fn.qyfrcomboboxforsearch = function () {
    var option = {
        loader:qyfrLoader,
        mode:'remote',
        valueField:'id',
        textField:'qyjc',
        panelHeight:'200'
    }
    this.combobox($.createArg(option, arguments));
    this.zwcomboboxbug();
}

$.fn.qyjgbmcombobox = function (paramOptions) {
    paramOptions.qyjgId = (typeof paramOptions.qyjgId == "undefined") ? null : paramOptions.qyjgId;
    var options = {
        url:$.webPath() + '/organ/qyjg/qyjgbmMcList?id=' + paramOptions.qyjgId,
        valueField:'id',
        textField:'qc',
        panelHeight:'200'
    };
    $.extend(options, paramOptions);
    this.combobox(options);
}

$.fn.bgjhlrjhdwcombobox = function (paramOptions) {
    paramOptions.ljId = (typeof paramOptions.ljId == "undefined") ? null : paramOptions.ljId;
    var options = {
        url:$.webPath() + '/organ/qyjg/qyjgjhdwMcList?ljId=' + paramOptions.ljId,
        valueField:'id',
        textField:'qc',
        panelHeight:'200'
    };
    $.extend(options, paramOptions);
    this.combobox(options);
}

$.fn.cghthzfcombobox = function (paramOptions) {
    paramOptions.ljId = (typeof paramOptions.ljId == "undefined") ? null : paramOptions.ljId;
    var options = {
        url:$.webPath() + '/organ/qyjg/cghthzfMcList?ljId=' + paramOptions.ljId,
        valueField:'id',
        textField:'qc',
        panelHeight:'200'
    };
    $.extend(options, paramOptions);
    this.combobox(options);
}

$.fn.qyjgwin = function (options) {
    var option = {
        title:"查询企业机构",
        searchTitle:"企业",
        width:600,
        height:500,
        multiple:true, //多选
        url:$.webPath() + '/organ/qyjg/qyjgList1', //查询url
        idField:"id", //唯一键
        textField:"jc", //显示前台名称
        columns:[
            //
            [
                {field:'id', title:'ID', hidden:true},
                {field:'qc', title:'企业全称', width:200},
                {field:'jc', title:'企业简称', width:100},
                {field:'lxr', title:'联系人', width:100},
                {field:'lxdh', title:'联系电话', width:100}
            ]
        ]
    }
    this.searchWin($.createArg(option, arguments));
}

$.fn.qyjgwinjhdw = function (options) {
    var option = {
        title:"查询计划单位",
        searchTitle:"企业",
        width:600,
        height:500,
        multiple:true, //多选
        url:$.webPath() + '/organ/qyjg/jhdwList', //查询url
        idField:"id", //唯一键
        textField:"jc", //显示前台名称
        columns:[
            //
            [
                {field:'id', title:'ID', hidden:true},
                {field:'qc', title:'企业全称', width:200},
                {field:'jc', title:'企业简称', width:100},
                {field:'bm', title:'编码', width:100},
                {field:'qyfr.qyqc', title:'企业法人', width:100}
            ]
        ]
    }
    this.searchWin($.createArg(option, arguments));
}
/**
 * 企业机构的combogrid
 */
$.fn.qyjgcombogrid = function (multi) {
    var options = {
        url:$.webPath() + '/organ/qyjg/qyjgmcList',
        loader:qyjgLoader,
        mode:"remote",
        panelWidth:500,
        panelHeight:250,
        idField:'id',
        textField:'jc',
        multiple:multi,
        fitColumns:true,
        pagination:true, //是否分页
        rownumbers:true, //序号
        collapsible:false, //是否可折叠的
        fit:true, //自动大小
        pageSize:10, //每页显示的记录条数，默认为10
        url:$.webPath() + '/organ/qyjg/qyjgList',
        columns:[
            [
                {field:'id', title:'ID', hidden:true},
                {field:'jc', title:'简称', width:250}
            ]
        ]
    };
    this.combogrid($.createArg(options, arguments));
    this.zwcombogridbug();
}

//物流商机构树
$.fn.wlscombobox = function () {
    var option = {
        url:$.webPath() + '/organ/wls/wlsInuseList',
        valueField:'id',
        textField:'qc',
        panelHeight:'200'
    }

    this.combobox($.createArg(option, arguments));
}

var qyjgLoader = function (param, success, error) {
    var q = param.q || '';
    if (q.length <= 1) {
        return false;
    }
    $.post($.webPath() + "/organ/qyjg/qyjgLoader", {
        zjm:q,
        jc:q,
        qc:q,
        maxRows:30
    }, function (data) {
        success(data);
    }, 'json');
}

var lskhLoader = function (param, success, error) {
    var q = param.q || '';
    if (q.length <= 1) {
        return false;
    }
    $.post($.webPath() + "/organ/qyjg/lskhLoader", {
        zjm:q,
        jc:q,
        qc:q,
        maxRows:30
    }, function (data) {
        success(data);
    }, 'json');
}

var qyfrLoader = function (param, success, error) {
    var q = param.q || '';
    if (q.length <= 1) {
        return false;
    }
    $.post($.webPath() + "/organ/qyfr/qyfrLoader", {
        qyfrJc:q,
        qyqc:q,
        maxRows:30
    }, function (data) {
        success(data);
    }, 'json');
}


$.fn.loadLocalRegion = function (region, value) {
    this.combobox('loadData', region);
    if (value)
        this.combobox('setValue', value);
}

